<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String orderId=request.getParameter("orderId");
%>
	<script>
	$(function(){
		$('#busId').combobox({   
		    url:'<%=path %>/busOrder/listUnUsedBus',
		   // required:true,
		    valueField:'id',   
		    textField:'bus_name',
		    onSelect:function(record){
		    	initEmp(record.id);
		    	
		    }
		});  
	})
	
		function initEmp(busId){
			$('#driverId').combobox({   
			    url:'<%=path %>/busOrder/lisUnUsedEmp?busId='+busId,
			   // required:true,
			    valueField:'id',   
			    textField:'name',
			    onLoadSuccess : function(){  
			        var val = $(this).combobox('getData');  
                    for (var item in val[0]) {  
                        if (item == 'id') {  
                            $(this).combobox('select', val[0][item]);  
                        }  
                    }  
		        }
			});
			
		}
		
	//关闭谈出窗口	
	function closeDag(){
		$('#orderSend').dialog('close'); 
	}
	
	//保存并分配 	
	function savaWithSend(){
		$.ajax({
    		type:"post",
    		url: '<%=path %>/busOrder/orderSend',
    		data:{
    			orderId:<%=orderId %>,
    			busId:$('#busId').combobox('getValue'),
    			driverId:$('#driverId').combobox('getValue'),
    			driverName:$('#driverId').combobox('getText')
			},
    		success: function (result) {
    			$('#list_data').datagrid("reload");
    			$('#orderSend').dialog('close');
    		}
	});
		
		
	}
	</script>
	<div id="tab_bd2">
		<div class="title">
			<div class="left">分发订单</div>
		</div>
		<div class="frame" style="width: 80%">
			<table  border="0" cellpadding="1" cellspacing="1"
				bordercolor="#CCCCCC" bgcolor="#CCCCCC" align="center">
				<tr>
					<td width="15%" class="lbg">分发车辆：</td>
					<td width="35%">
					<input type="text" class="easyui-validatebox"
						data-options="required:true" id="busId" />
					</td>
				</tr>
				<tr>
					<td width="15%" class="lbg">相关司机：</td>
					<td width="35%"><input type="text" class="easyui-validatebox"
						 id="driverId" 
						>
					</td>
				</tr>
				<tr>
					<td width="15%" class="lbg">是否消息发放：</td>
					<td width="35%">
						<input type="checkbox" name="isSendMsg" value="1" checked="checked">微信发送&nbsp;&nbsp;&nbsp;
						<input type="checkbox" name="isSendMsg" value="2" checked="checked">短信发送发送&nbsp;&nbsp;&nbsp;
					</td>
				</tr>
				<tr>
						<td colspan="2" align="center">
						<a href="javascript:savaWithSend()" class="easyui-linkbutton pad" iconCls="icon-redo">分发</a>
						<a href="javascript:closeDag()" class="easyui-linkbutton pad" iconCls="icon-reload">返回</a>
						</td>
				
				</tr>
			</table>
		</div>
	</div>
	
